$(document).ready(function(){
		$("ul.treeview:first").Treeview();
		$("ul.treeview:eq(1), ul.treeview:eq(2)").Treeview({ control: "#treecontrol" });
		var lastTree = $("ul.treeview:last").Treeview({
			speed: "fast",
			collapsed: true,
			unique: true,
			toggle: function() {
				window.console && console.log && console.log("%o was toggled", $(this).parent());
			}
		});
	});

/*
function primaryClickHandler(root) {
	$('a',root).click(function(){
		$('.subnav').slideUp('slow');
		$('.subnav').load(this.href,function(){
    		$('.subnav').slideDown('slow');
			secondryClickHandler($('.subnav'));
		});
		return false;
	});
};

function secondryClickHandler(root) {
	$('a',root).click(function(){
		$('.content').load(this.href,function(){
    		contentClickHandler($('.content'));
		});
		return false;
	});
};

function contentClickHandler(root) {
	$('a',root).click(function(){
		var type = $(this).attr('class');
		switch (type)
		{
		case ".sublink":
			$('.subnav').load(this.href,function(){
				secondryClickHandler($('.subnav'))});
			break;
		default:	
			$('.content').load(this.href,function(){
    			contentClickHandler($('.content'))});
		}
		return false;
	});
}

function noAjaxHandler(root)
{
	$('a.no-ajax', root).click(function(){
		window.open(this.href);
		return false;
	});
};

$('document').ready(function() {
	primaryClickHandler('.primarynav');
    contentClickHandler('.content');
	noAjaxHandler(document);
	$('.subnav').load('/posts/getposts/5', function(){
		$('.subnav').show('slow');
		secondryClickHandler('.subnav');
	});
});
*/

function paginationNext(root)
{
	$('.next a',root).click(function(){
		$(root).load(this.href, function(){
			paginationNext(root);
			paginationPrev(root);	
		});
	});
};

function paginationPrev(root)
{
	$('.previous a',root).click(function(){
		$(root).load(this.href, function(){
			paginationNext(root);
			paginationPrev(root);	
		});
	});
};

function showCommentForm()
{
	$('.comment-add').bind('click', function(){
		$('.comment-ajax').load(this.href, function(){
			$('.comment-ajax').show('fast');
		});
		return false;
	});
}

$(document).ready(function(){
	paginationNext('.content');
	paginationPrev('.content');
	showCommentForm();
});

// AJAX BlockUI Elements
$.blockUI.defaults.pageMessage = '<img src="/img/loading.gif" class="loading" />';
$.extend($.blockUI.defaults.pageMessageCSS, { color: '#f00', backgroundColor: '#000' });
$().ajaxStart($.blockUI);
$().ajaxStop($.unblockUI);